package com.inspectortime.common;

import java.io.Serializable;
import java.util.Collection;

/**
 * Handy utilities for Identifiable objects
 * 
 * @author mkvalsvik
 * 
 */
public final class IdentifiableUtils {

	private IdentifiableUtils() {
	}

	public static Identifiable findById(Collection<?extends Identifiable> coll, Serializable id) {
		for (Identifiable obj : coll) {
			if (obj.getId().equals(id)) {
				return obj;
			}
		}
		return null;
	}
	
	public static void removeById(Collection<?extends Identifiable> coll, Serializable id) {
		Object obj = findById(coll, id);
		if (obj != null) {
			coll.remove(obj);
		}
	}
}
